package com.hhxy.stream;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Stream;

public class StreamDemo {
    public static void main(String[] args) {
        //1.Collection集合创建Stream流
        Collection<String> list = new ArrayList<>();
        Stream<String> listStream = list.stream();

        //2.Map集合创建Stream流
        Map<String,Integer> map = new HashMap<>();
        //创建键(key)流
        Stream<String> keyStream = map.keySet().stream();
        //创建值(value)流
        Stream<Integer> valueStream = map.values().stream();
        //创建键值对流
        Stream<Map.Entry<String, Integer>> keyAndValueStream = map.entrySet().stream();

        //3.字符串数组创建Stream流
        String[] names = {"张三","李四","王五"};



        //方式1：
        Stream<String> arrStream1 = Arrays.stream(names);
        //方式2：
        Stream<String> arrStream2 = Stream.of(names);
//        arrStream1.map(s->"a"+s).forEach(System.out::println);
        arrStream1.map(s->s+"b").forEach(System.out::println);
/*        arrStream1.map(new Function<String, String>() {
            @Override
            public String apply(String s) {
                return null;
            }
        });*/
    }
}